import pygame
import spyral
import math

import Dic


class Instruction(spyral.sprite.Sprite):
    def __init__(self):
        spyral.sprite.Sprite.__init__(self)
        self.image = pygame.image.load(Dic.images['instr5seconds'])
        self.rect.center = (480, 320);
        self.layer = 2;
        self.alpha = 0;
        self.image.set_alpha(self.alpha)
        self.instruction = 1;
        self.up = True;
        
    def update(self, tick):
        if (self.instruction == 1):
            if (self.up):
                self.alpha += 25
                if (self.alpha >= 255):
                    self.up = False;
            elif (self.alpha > 0):
                self.alpha -= 7;
            else:
                self.alpha = 0;
                self.up = True;
                self.instruction += 1;
                self.image = pygame.image.load(Dic.images['instrready'])
        elif (self.instruction == 2):
            if (self.up):
                self.alpha += 25
                if (self.alpha >= 255):
                    self.up = False;
            elif (self.alpha > 0):
                self.alpha -= 7;
            else:
                self.alpha = 0;
                self.up = True;
                self.instruction += 1;
                self.image = pygame.image.load(Dic.images['instrset'])
        elif (self.instruction == 3):
            if (self.up):
                self.alpha += 25
                if (self.alpha >= 255):
                    self.up = False;
            elif (self.alpha > 0):
                self.alpha -= 7;
            else:
                self.kill();
        self.image.set_alpha(self.alpha)
        self.image = self.image.copy()
        
        